<?php
defined("_ALLOW") or die ("Access denied");
$task = $_GET['task'];
include_once("class/cproduct.php");
include_once("class/cproductcategory.php");
include_once("class/cproductsection.php");
global $objproductsection;
global $objproductcategory;
global $objproduct;
$urlpaging = "";
$urlpaging  = "index.php?module=com_product&task=blogcategory";
if ($task=="blogcategory") {
	$catid = $_GET['id'];
	$urlpaging .= "&id=" . $catid;
}
else if ($task=="view") {
	$id =$_GET['id'];
	$objproduct = $objproduct->Doc($id);
	$catid = $objproduct->catid;
}
else if ($task=="blogsection") {
	$urlpaging  = "index.php?module=com_product&task=blogsection";
	$sid = $_GET['id'];
	$urlpaging .= "&id=" . $sid;
}
else{
	$urlpaging  = "index.php?module=com_product&task=viewall";
}
if (isset($_GET['Itemid'])) {
	$itemid = $_GET['Itemid'];
	$urlpaging .= "&Itemid=$itemid";
}
?>
<script language="javascript">
var url = "<?php echo $urlpaging; ?>";
function GotoPage (page) {
	var urltopage;
	urltopage = url + "&curPage=" + page;
	location.href = urltopage;
//	Ajax_Goto(url);
}
</script>
<?php
global $maxwidthimage;
global $cfg_scale_widthproduct;
switch ($task) {
	case "view":
		global $cfg_full_widthproduct;
?>
<div class="title_productcategory">
<?php
	$objproductcategory = $objproductcategory->Doc($catid);
	$objproductcategory->Out_Title_Link();
?>
</div>
<div class="td_bodyproduct">
<?php echo $objproduct->Out_TheHien(300); ?>
</div>
<?php
global $lang;
global $totalRows;
$maxRows = 5;
$idproduct = $objproduct->id;
$orderproduct = $objproduct->order;
/////////Các sản phẩm đã đưa//////////////////
$strwhere = "catid=$catid AND iorder >= $orderproduct AND id <> $idproduct";
$totalRows = $objproduct->CountFill($strwhere);
if ($totalRows > 0) {
?>
<div class="title_list_foot"><?php if ($lang=="vn") echo "Các sản phẩm khác"; else echo "Other products"; ?></div>
<div class="td_listproduct_foot">
  <?php
	$begin = $totalRows - $maxRows;
	if ($begin < 0) $begin = 0;
	$array = $objproduct->Fill($strwhere, $maxRows, $begin);
	include_once("common/paging.php");
	$maxwidthimage = $cfg_scale_widthproduct;
	Paging_content_foot($array, 1);
?>
</div>
<?php
}
		break;
	case "blogcategory":
?>
<div class="title_productcategory">
<?php
	$objproductcategory = $objproductcategory->Doc($catid);
	$objproductsection = $objproductsection->Doc($objproductcategory->sid);
	echo "Bất động sản ".$objproductsection->Get_Title()." - ".$objproductcategory->Get_Title();
?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
  	$totalRows = $objproduct->CountFill("catid=" . $catid);
	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Doc_danh_sach($catid, $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		include("listproject.php");
		
		echo $paging;
	}
  ?>
</div>
<?php
		break;
	case "viewall":
?>
<div class="title_productcategory">
<?php
//	$objproductcategory = $objproductcategory->Doc($catid);
//	$objproductsection = $objproductsection->Doc($objproductcategory->sid);
	echo "Bất động sản ";
?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
  	$totalRows = $objproduct->CountFill("");
	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Fill("", $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		include("listproject.php");
		
		echo $paging;
	}
  ?>
</div>


<?php
		break;
	case "viewduan":
?>
<div class="title_productcategory">
<?php
//	$objproductcategory = $objproductcategory->Doc($catid);
//	$objproductsection = $objproductsection->Doc($objproductcategory->sid);
	echo "Đất dự án ";
?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
	$strwhere = "catid=171 or catid=164 or catid=157 or catid=150 or catid=143 or catid=136 or catid=129 or catid=122 or catid=115 or catid=108 or catid=101 or catid=94 or catid=87 or catid=80 or catid=73 or catid=66 or catid=59 or catid=52 or catid=45 or catid=38 or catid=31 or catid=24 or catid=17 or catid=10 or catid=1";
  	$totalRows = $objproduct->CountFill($strwhere);
	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Fill($strwhere, $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		include("listproject.php");
		
		echo $paging;
	}
  ?>
</div>

<?php
		break;
	case "viewvuon":
?>
<div class="title_productcategory">
<?php
//	$objproductcategory = $objproductcategory->Doc($catid);
//	$objproductsection = $objproductsection->Doc($objproductcategory->sid);
	echo "Đất vườn";
?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
	$strwhere = " catid=172 or catid=165 or catid=158 or catid=151 or catid=146 or catid=137 or catid=130 or catid=123 or catid=116 or catid=109 or catid=102 or catid=95 or catid=88 or catid=81 or catid=74 or catid=67 or catid=60 or catid=53 or catid=46 or catid=39 or catid=32 or catid=25 or catid=18 or catid=11 or catid=2 ";
  	$totalRows = $objproduct->CountFill($strwhere);
	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Fill($strwhere, $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		include("listproject.php");
		
		echo $paging;
	}
  ?>
</div>

<?php
		break;
	case "viewruong":
?>
<div class="title_productcategory">
<?php
//	$objproductcategory = $objproductcategory->Doc($catid);
//	$objproductsection = $objproductsection->Doc($objproductcategory->sid);
	echo "Đất ruộng";
?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
	$strwhere = " catid=173 or catid=166 or catid=159 or catid=152 or catid=145 or catid=138 or catid=124 or catid=117 or catid=110 or catid=103 or catid=96 or catid=89 or catid=82 or catid=75 or catid=68 or catid=61 or catid=54 or catid=47 or catid=40 or catid=33 or catid=26 or catid=19 or catid=12 or catid=3 or catid=195 or catid=196 or catid=197 or catid=198 ";
  	$totalRows = $objproduct->CountFill($strwhere);
	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Fill($strwhere, $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		include("listproject.php");
		
		echo $paging;
	}
  ?>
</div>

<?php
		break;
	case "viewthocu":
?>
<div class="title_productcategory">
<?php
//	$objproductcategory = $objproductcategory->Doc($catid);
//	$objproductsection = $objproductsection->Doc($objproductcategory->sid);
	echo "Đất thổ cư";
?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
	$strwhere = " catid=174 or catid=167 or catid=160 or catid=153 or catid=146 or catid=139 or catid=132 or catid=125 or catid=118 or catid=111 or catid=104 or catid=97 or catid=90 or catid=83 or catid=76 or catid=69 or catid=62 or catid=55 or catid=48 or catid=41 or catid=34 or catid=27 or catid=20 or catid=13 or catid=4 or catid=181 or catid=199 or catid=200 or catid=201 or catid=202";
  	$totalRows = $objproduct->CountFill($strwhere);
	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Fill($strwhere, $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		include("listproject.php");
		
		echo $paging;
	}
  ?>
</div>

<?php
		break;
	case "viewnhaduan":
?>
<div class="title_productcategory">
<?php
//	$objproductcategory = $objproductcategory->Doc($catid);
//	$objproductsection = $objproductsection->Doc($objproductcategory->sid);
	echo "Nhà dự án";
?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
	$strwhere = " catid=175 or catid=168 or catid=161 or catid=154 or catid=147 or catid=140 or catid=126 or catid=119 or catid=112 or catid=105 or catid=98 or catid=91 or catid=84 or catid=77 or catid=70 or catid=63 or catid=56 or catid=19 or catid=42 or catid=35 or catid=28 or catid=21 or catid=14 or catid=7 or catid=182 or catid=203 or catid=206 or catid=208 or catid=209";
  	$totalRows = $objproduct->CountFill($strwhere);
	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Fill($strwhere, $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		include("listproject.php");
		
		echo $paging;
	}
  ?>
</div>

<?php
		break;
	case "viewkhudancu":
?>
<div class="title_productcategory">
<?php
//	$objproductcategory = $objproductcategory->Doc($catid);
//	$objproductsection = $objproductsection->Doc($objproductcategory->sid);
	echo "Nhà khu dân cư";
?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
	$strwhere = " catid=176 or catid=169 or catid=162 or catid=155 or catid=148 or catid=134 or catid=127 or catid=120 or catid=113 or catid=106 or catid=99 or catid=92 or catid=85 or catid=78 or catid=71 or catid=64 or catid=57 or catid=50 or catid=43 or catid=36 or catid=29 or catid=22 or catid=15 or catid=8 or catid=183 or catid=204 or catid=205 or catid=207 or catid=210";
  	$totalRows = $objproduct->CountFill($strwhere);
	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Fill($strwhere, $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		include("listproject.php");
		
		echo $paging;
	}
  ?>
</div>

<?php
		break;
	case "viewchungcu":
?>
<div class="title_productcategory">
<?php
//	$objproductcategory = $objproductcategory->Doc($catid);
//	$objproductsection = $objproductsection->Doc($objproductcategory->sid);
	echo "Chung cư";
?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
	$strwhere = " catid=177 or catid=170 or catid=163 or catid=156 or catid=149 or catid=142 or catid=128 or catid=121 or catid=114 or catid=107 or catid=100 or catid=93 or catid=86 or catid=79 or catid=72 or catid=65 or catid=58 or catid=51 or catid=44 or catid=37 or catid=30 or catid=23 or catid=16 or catid=9 or catid=184 or catid=211 or catid=212 or catid=213 or catid=214";
  	$totalRows = $objproduct->CountFill($strwhere);
	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Fill($strwhere, $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		include("listproject.php");
		
		echo $paging;
	}
  ?>
</div>

<?php
		break;
	case "blogsection":
?>
<div class="title_productcategory">
<?php
//	include_once("class/cproductsection.php");
//	global $objproductsection;
	$objproductsection = $objproductsection->Doc($sid);
	echo "Bất động sản ".$objproductsection->Get_Title();

?>
</div>
<div class="td_listproduct_tt">
  <?php
	global $totalRows;
  	$totalRows = $objproduct->CountFill("sid=$sid");

	if ($totalRows > 0) {
		$pagingcolumns = 2;
		global $maxRows;
		$maxRows = 50;
		global $maxPages;
		$maxPages = 5;
		include_once("common/paging.php");
		global $curPage;
		$paging = Paging_GetPaging();
		$beginrow = ($curPage-1) * $maxRows;
		global $array;
		$array = $objproduct->Fill("sid=" . $sid, $maxRows, $beginrow);
		$maxwidthimage = $cfg_scale_widthproduct;
		//Paging_List_Content_TT ($array, $pagingcolumns);
		include("listproject.php");
		echo $paging;
	}
  ?>
</div>
<?php
	break;
	default:
		die("Address Fail");
}
?>